
import os,zipfile
import re
import sys
path = r"E:\2019PythonProject\20200903SprayData\Tarpa4Class\cover"
fileList = os.listdir(path) 
img_num = 0
for fileName in fileList:
    try:
        new_name_1 =str(fileName.split('(')[0].strip())
        new_name_2 =str( fileName.split('(')[1].split(')')[0])
        new_name = new_name_1 +'_' +new_name_2 + '.' + fileName.split('.')[-1]
        os.rename(path +'/'+ fileName,path+'/'+ new_name)  # 文件重新命名
    except:
        print(fileName)
    img_num += 1   
print(img_num)
